home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmtoolBox
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- ClientHeight = 5985
- ClientLeft = 2040
- ClientTop = 1725
- ClientWidth = 1170
- ClipControls = 0 'False
- ControlBox = 0 'False
- Height = 6390
- Icon = 0
- KeyPreview = -1 'True
- Left = 1980
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 399
- ScaleMode = 3 'Pixel
- ScaleWidth = 78
- Top = 1380
- Width = 1290
- Begin PictureBox MsgBlaster1
- BackColor = &H000000FF&
- Height = 1000
- Left = 0
- ScaleHeight = 975
- ScaleWidth = 975
- TabIndex = 0
- Top = 0
- Width = 1000
- End
- Begin Shape Shape1
- BorderColor = &H80000006&
- Height = 5985
- Left = 0
- Top = 0
- Width = 1170
- End
- Option Explicit
- Dim toolBoxActive As Integer
- Dim hSysMenu As Long
- 'Menu ID's
- Const IDM_SYSMOVE = 101
- Const IDM_SYSCLOSE = 102
- Sub Form_KeyDown (keyCode As Integer, Shift As Integer)
- If (keyCode = 32) And (Shift = 4) Then
- keyCode = 0
- Shift = 0
- DoEvents
- ShowSysMenu
- End If
- If (keyCode = 115) And (Shift = 4) Then
- keyCode = 0
- Shift = 0
- frmMain!mnuToolbox.Checked = False
- Hide
- End If
- End Sub
- Sub Form_Load ()
- Dim i%
- ' Make the toolbox a top-most window
- i% = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
- ' Set up message blaster to respond to desired events...
- MsgBlaster1.hWndTarget = hWnd
- MsgBlaster1.MsgList(0) = WM_NCHITTEST
- MsgBlaster1.MsgPassage(0) = EATMESSAGE
- MsgBlaster1.MsgList(1) = WM_CLOSE
- MsgBlaster1.MsgList(2) = WM_NCACTIVATE
- MsgBlaster1.MsgList(3) = WM_NCLBUTTONDBLCLK
- MsgBlaster1.MsgPassage(3) = EATMESSAGE
- MsgBlaster1.MsgList(4) = WM_NCLBUTTONDOWN
- MsgBlaster1.MsgList(5) = WM_COMMAND
- MsgBlaster1.MsgPassage(5) = PREPROCESS
- MsgBlaster1.MsgList(6) = WM_ACTIVATEAPP
- ' Create our fake system menu for the toolbox
- ' (I don't use VBs own popup menu function because it lacks
- ' the full functionality of the API function)
- hSysMenu = CreatePopupMenu()
- i% = AppendMenu(hSysMenu, MF_ENABLED Or MF_STRING, IDM_SYSMOVE, "&Move")
- i% = AppendMenu(hSysMenu, MF_ENABLED Or MF_STRING, IDM_SYSCLOSE, "&Close Alt+F4")
- End Sub
- Sub Form_Paint ()
- 'Refresh the title bar and system menu. The paint event gets
- 'called each time the system colors are changed, so we keep
- 'up to date on the fly...
- 'Vertical line beteen control menu and caption
- '(using the windowframe system color)
- Line (BAR_HEIGHT + 1, 1)-(BAR_HEIGHT + 1, BAR_HEIGHT + 1), WINDOW_FRAME
- 'Horizontal line below caption (using the windowframe
- 'system color)
- Line (1, BAR_HEIGHT + 1)-(scaleWidth, BAR_HEIGHT + 1), WINDOW_FRAME
- 'Fill in control menu (always light gray)
- Line (1, 1)-(BAR_HEIGHT, BAR_HEIGHT), QBColor(7), BF
- 'Box for bar in control menu (always black)
- Line (2, (BAR_HEIGHT - 1) \ 2)-Step(BAR_HEIGHT - 4, 2), QBColor(0), B
- 'Line inside bar in control menu (always white)
- Line (3, (BAR_HEIGHT - 1) \ 2 + 1)-Step(BAR_HEIGHT - 5, 0), QBColor(15)
- 'Vertical shadow on bar in control menu (always dark gray)
- Line (BAR_HEIGHT - 1, (BAR_HEIGHT - 1) \ 2 + 1)-Step(0, 3), QBColor(8)
- 'Horizontal shadow on bar in control menu (always dark gray)
- Line (3, (BAR_HEIGHT - 1) \ 2 + 3)-Step(BAR_HEIGHT - 4, 0), QBColor(8)
- titleBar
- End Sub
- Sub MsgBlaster1_Message (MsgVal As Integer, wParam As Integer, lParam As Long, lRetVal As Long)
- Dim i%, tc&
- Dim FormTop%
- Dim FormLeft%
- Dim xPos%
- Dim yPos%
- 'Which message has come to us?
- Select Case MsgVal
- Case WM_ACTIVATEAPP
- 'The WM_ACTIVATEAPP message means our app is losing or
- 'gaining the focus. We check this so we can show or hide
- 'the floating toolbox.
- If wParam Then
- If frmMain.WindowState <> 1 And frmMain!mnuToolbox.Checked Then frmToolBox.Show
- Else
- Hide
- End If
- lRetVal = 0
- Case WM_NCACTIVATE
- 'The WM_NCACTIVATE message means the non-client area of a
- 'window requires updating due to a change in the activation
- 'state of that window. All we need to redraw is the title
- 'bar.
- If wParam Then
- toolBoxActive = True
- Else
- toolBoxActive = False
- End If
- titleBar
- Case WM_CLOSE
- 'Close has been selected from the system menu.
- frmMain!mnuToolbox.Checked = False
- Hide
- Case WM_NCHITTEST
- 'This is the magic bit - windows tells us that the user is
- 'moving the mouse over our window - it wants us to tell it
- 'WHAT the mouse is moving over, so we oblige. Then, when
- 'the user clicks, windows thinks the user has clicked on
- 'whatever we have told it the mouse was over.
- FormTop% = top / screen.TwipsPerPixelY
- FormLeft% = Left / screen.TwipsPerPixelX
- xPos% = (lParam And &HFFFF&) - FormLeft%
- yPos% = (lParam / 65536) - FormTop%
- If (yPos% < BAR_HEIGHT + 2) And (xPos% < BAR_HEIGHT + 2) Then
- 'Tell windows the mouse is over the system menu...
- lRetVal = HTSYSMENU
- ElseIf (yPos% < BAR_HEIGHT + 2) Then
- 'Tell windows the mouse is over the title bar...
- lRetVal = HTCAPTION
- Else
- ' Tell windows the mouse is over the client area...
- lRetVal = HTCLIENT
- End If
- Case WM_NCLBUTTONDBLCLK
- 'A double click in the non-client area! If it is over the
- 'system menu then we close (hide) the toolbox...
- If wParam = HTSYSMENU Then
- frmMain!mnuToolbox.Checked = False
- Hide
- End If
- Case WM_NCLBUTTONDOWN
- 'A buttondown in the non-client area! If it is over the
- 'system menu then we show the system menu...
- If wParam = HTSYSMENU Then
- ShowSysMenu
- End If
- Case WM_COMMAND
- 'A command message (meaning a command button or menu-item
- 'has been selected).
- Select Case wParam
- Case IDM_SYSMOVE
- 'If the move menu item was selected, send a move command.
- tc& = SendMessage(hWnd, WM_SYSCOMMAND, SC_MOVE, 0)
- Case IDM_SYSCLOSE
- 'If the close menu item was selected, close the window.
- frmMain!mnuToolbox.Checked = False
- Hide
- End Select
- End Select
- End Sub
- Sub ShowSysMenu ()
- Dim ScreenRect As Rect
- Dim InPixels As Single
- Dim IX As Single
- Dim IY As Single
- Dim RC%
- 'Set up the rectangle that defines an area where the mouse
- 'can be clicked without dismissing the menu. This lets the
- 'user click and release over the system menu and the menu
- 'stays up. VBs built in popup menu function doesn't support
- 'this.
- ScaleMode = 1
- ScreenRect.Left = Left \ screen.TwipsPerPixelX
- ScreenRect.Right = ScreenRect.Left + BAR_HEIGHT + 2
- ScreenRect.top = top \ screen.TwipsPerPixelY
- ScreenRect.bottom = ScreenRect.top + BAR_HEIGHT + 2
- ScaleMode = 3
- IX = ScreenRect.Left
- IY = ScreenRect.bottom - 1
- 'If the menu will go off the bottom of the screen, make it
- 'draw ABOVE the control box. Note that Windows won't draw a
- 'menu off the screen, but it will draw it covering the control
- 'box. Normal control menus don't do this.
- If (IY + 2 * GetSystemMetrics(SM_CYMENU) + 3) > (screen.Height \ screen.TwipsPerPixelY) Then IY = IY - (2 * GetSystemMetrics(SM_CYMENU)) - 12
- RC% = TrackPopupMenu(hSysMenu, 0, IX, IY, 0, hWnd, ScreenRect)
- End Sub
- Sub titleBar ()
- 'Paint titleBar
- If toolBoxActive Then
- 'If the toolbox is the active window then paint
- 'with the active title bar color
- Line (BAR_HEIGHT + 2, 1)-Step(scaleWidth - BAR_HEIGHT - 4, BAR_HEIGHT - 1), ACTIVE_TITLE_BAR, BF
- Else
- 'If the toolbox is inactive then paint with the
- 'inactive title bar color
- Line (BAR_HEIGHT + 2, 1)-Step(scaleWidth - BAR_HEIGHT - 4, BAR_HEIGHT - 1), INACTIVE_TITLE_BAR, BF
- End If
- End Sub
-